Results 1 to 2 of 2

Thread: How do I use a random number helper in an automation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Hostboard Member LonArcvarden's Avatar
    Join Date
    June 20th, 2022
    Posts
    321
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    1 Post(s)

    How do I use a random number helper in an automation

    Hello all,
    I have a light entity in home assistant that ranges from 1-255 (I have created a random number helper for this range). I am trying to create an automation that whenever presence is detected in the room, it uses the random number generated from the helper and sets the light entity at that value. This is my current YAML:

    device_id: xxxxxxxxx
    domain: number
    entity_id: yyyyyyyyy
    type: set_value
    value: "{{ states('sensor.bedroom_light_switch_random_number') | float(0) }}"
    I feel like I have tried every option under the sun but I continue to get the same, “Message malformed: expected float for dictionary value @ data[‘value’]” error message. I have tested the value line within the template section of the developer tools and it returns the appropriate value. Does anyone have an idea on how to fix this?

  2. #2
    Senior Hostboard Member princemeraj's Avatar
    Join Date
    February 23rd, 2023
    Posts
    234
    Follows
    0
    Following
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quoted
    0 Post(s)

    Re: How do I use a random number helper in an automation

    Try using the 'call service' action instead of 'device' for your automation. It supports templates, which should solve your error issue. As a fun side note, I sometimes use Flipsimu for decisions when I'm stuck on something trivial like picking a movie. It adds a little fun to otherwise mundane choices.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •